﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetNotBangdingTeam]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetNotBangdingTeam];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetNotBangdingTeam]
    @FlowID int,
    @StepID int
AS
BEGIN
SET NOCOUNT ON;

SELECT
		classid as Team_ID,
		classname as Team_Name
    FROM
        dbo.uds_class
    WHERE classid not in
		(
            SELECT b.classid
            FROM
                dbo.uds_flow_member_bind a ,
                dbo.uds_class b
            WHERE
				a.obj_id = b.classid
                and a.flow_id = @flowid
                and a.step_id = @stepid
                and a.obj_type = 2
        )
        and classtype <= 1;

END
GO